package com.baway.home.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.baway.common.entity.NoticeEntity
import com.baway.home.databinding.NoticeItemLayoutBinding

/**
 * Author: Jason Zhang
 * Date: 2025/8/28
 * Desc:
 */
class NoticeListAdapter(private val data: MutableList<NoticeEntity>): RecyclerView.Adapter<NoticeListAdapter.NoticeItemViewHolder>(){


    inner class NoticeItemViewHolder(val itemDataBinding: NoticeItemLayoutBinding): RecyclerView.ViewHolder(itemDataBinding.root)

    override fun getItemCount(): Int = data.size

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NoticeItemViewHolder {
       return NoticeItemViewHolder(NoticeItemLayoutBinding.inflate(LayoutInflater.from(parent.context), parent, false ))
    }


    override fun onBindViewHolder(holder: NoticeItemViewHolder, position: Int) {
        val noticeEntity = data[position]
        holder.itemDataBinding.run {
            entity = noticeEntity
            executePendingBindings()
        }


    }


}